package ren.kane.asdppp.transaction.employee;

import org.springframework.stereotype.Service;
import ren.kane.asdppp.PayrollDatabase;
import ren.kane.asdppp.affiliation.Affiliation;
import ren.kane.asdppp.affiliation.NoAffiliation;
import ren.kane.asdppp.classification.PaymentClassification;
import ren.kane.asdppp.method.HoldMethod;
import ren.kane.asdppp.method.PaymentMethod;
import ren.kane.asdppp.schedule.PaymentSchedule;
import ren.kane.asdppp.Employee;
import ren.kane.asdppp.transaction.Transaction;

/**
 * @author renrk(1275) on 2019-04-09 7:00 PM
 **/
@Service
public abstract class AddEmployeeTransaction implements Transaction {

    private int itsEmpId;

    private String itsName;

    private String itsAddress;

    public AddEmployeeTransaction() {
    }

    public AddEmployeeTransaction(int empId, String name, String address) {
        itsEmpId = empId;
        itsName = name;
        itsAddress = address;
    }

    @Override
    public void execute() {
        PaymentClassification paymentClassification = getClassification();
        PaymentSchedule paymentSchedule = getSchedule();
        PaymentMethod paymentMethod = new HoldMethod();
        Affiliation affiliation = new NoAffiliation();
        Employee employee = new Employee(itsEmpId, itsName, itsAddress);
        employee.setPaymentClassification(paymentClassification);
        employee.setPaymentSchedule(paymentSchedule);
        employee.setPaymentMethod(paymentMethod);
        employee.setAffiliation(affiliation);
        PayrollDatabase.addEmployee(itsEmpId, employee);
    }

    protected abstract PaymentClassification getClassification();

    protected abstract PaymentSchedule getSchedule();
}
